package com.github_Dididipapa.shortlink.project.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @description: To be defined
 * @author: dididi_papa
 * @email: mitis1624087624@gmail.com
 * @date: 2025/10/17  15:58
 */
@Configuration
public class RabbitMQConfig {

    @Bean
    public DirectExchange exchange() {
        // 创建持久化的Topic交换机
        // TopicExchange(String name, boolean durable, boolean autoDelete)
        return new DirectExchange("ip-monitor", true, false);
    }

    @Bean
    public Queue accessStatsQueue() {
        // 创建持久化队列
        // Queue(String name, boolean durable, boolean exclusive, boolean autoDelete)
        return new Queue("accessStats", true, false, false);
    }

    @Bean
    public Queue localStatsQueue() {
        // 创建持久化队列
        // Queue(String name, boolean durable, boolean exclusive, boolean autoDelete)
        return new Queue("localStats", true, false, false);
    }

    @Bean
    public Queue osStatsQueue() {
        // 创建持久化队列
        // Queue(String name, boolean durable, boolean exclusive, boolean autoDelete)
        return new Queue("osStats", true, false, false);
    }

    @Bean
    public Queue browserStatsQueue() {
        // 创建持久化队列
        // Queue(String name, boolean durable, boolean exclusive, boolean autoDelete)
        return new Queue("browserStats", true, false, false);
    }

    @Bean
    public Queue linkAccessLogsQueue() {
        // 创建持久化队列
        // Queue(String name, boolean durable, boolean exclusive, boolean autoDelete)
        return new Queue("linkAccessLogs", true, false, false);
    }

    @Bean
    public Queue linkDeviceStatsQueue() {
        // 创建持久化队列
        // Queue(String name, boolean durable, boolean exclusive, boolean autoDelete)
        return new Queue("linkDeviceStats", true, false, false);
    }

    @Bean
    public Queue linkNetworkStatsQueue() {
        // 创建持久化队列
        // Queue(String name, boolean durable, boolean exclusive, boolean autoDelete)
        return new Queue("linkNetworkStats", true, false, false);
    }


    @Bean
    public Binding bindingQueueToExchange(Queue localStatsQueue, DirectExchange exchange) {
        return BindingBuilder.bind(localStatsQueue).to(exchange).with("localStats");
    }

    @Bean
    public Binding bindingDirectQueueToExchange(Queue accessStatsQueue, DirectExchange exchange) {
        return BindingBuilder.bind(accessStatsQueue).to(exchange).with("accessStats");
    }
    
    @Bean
    public Binding bindingOsStatsQueueToExchange(Queue osStatsQueue, DirectExchange exchange) {
        return BindingBuilder.bind(osStatsQueue).to(exchange).with("osStats");
    }
    
    @Bean
    public Binding bindingBrowserStatsQueueToExchange(Queue browserStatsQueue, DirectExchange exchange) {
        return BindingBuilder.bind(browserStatsQueue).to(exchange).with("browserStats");
    }
    
    @Bean
    public Binding bindingLinkAccessLogsQueueToExchange(Queue linkAccessLogsQueue, DirectExchange exchange) {
        return BindingBuilder.bind(linkAccessLogsQueue).to(exchange).with("linkAccessLogs");
    }
    
    @Bean
    public Binding bindingLinkDeviceStatsQueueToExchange(Queue linkDeviceStatsQueue, DirectExchange exchange) {
        return BindingBuilder.bind(linkDeviceStatsQueue).to(exchange).with("linkDeviceStats");
    }
    
    @Bean
    public Binding bindingLinkNetworkStatsQueueToExchange(Queue linkNetworkStatsQueue, DirectExchange exchange) {
        return BindingBuilder.bind(linkNetworkStatsQueue).to(exchange).with("linkNetworkStats");
    }
}
